package com.sds.shop.action;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sds.fw.mvc.Action;
import com.sds.fw.mvc.HttpUtil;
import com.sds.shop.dao.MemDAO;
import com.sds.shop.dao.OrderDAO;
import com.sds.shop.vo.MemVO;
import com.sds.shop.vo.MyOrderVO;
import com.sds.shop.vo.OrderVO;
import com.sds.shop.vo.SessionVO;

public class OrderFormAction extends Action{

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		HttpSession session = request.getSession();
		String path = "";

		
		boolean isLogin = false;
		Date today=new Date();
	    SimpleDateFormat formater = new SimpleDateFormat("yyyyMMddHHmmss");
	    SessionVO svo = (SessionVO)session.getAttribute("user");
		MemVO member= new MemVO();
		MemDAO mdao = new MemDAO();
		member=mdao.getCustomer(svo.getMemId());
		OrderVO ovo = new OrderVO();
		OrderDAO odao = new OrderDAO();
		ovo.setOrdNo(odao.getOrdNumber());
		ovo.setMemId(member.getMemId());
		ovo.setOrdAmt(Integer.parseInt(request.getParameter("totalPrice")));
		ovo.setRcvrNm(member.getMemNm());
		ovo.setRcvrTelno(member.getTelNo());
		ovo.setRcvrAddr(member.getAddr());
		System.out.println(ovo.getRcvrAddr());
		request.setAttribute("orderinfo", ovo);
		session.setAttribute("totalPrice", request.getParameter("totalPrice"));
		session.setAttribute("countBasket", request.getParameter("countBasket"));
		HttpUtil.forward(request, response, "/jsp/order.jsp");
	}	
}